<%
var headerPart = {
%>
<script type="text/javascript">
    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
</script>
<% }; %>
<% layout("/layouts/micro.html",{headerSection:headerPart}){ %>
<div class="layui-fluid">
	<div class="layui-card">
	<!--<ul class="layui-tab-title">
		<li class="layui-this"><a href="${ctx}/cms/site/">站点列表</a></li>
		<%if(shiro.hasPermission("cms:site:edit")){%><li><a href="${ctx}/cms/site/form">站点添加</a></li><%}%>
	</ul>-->
	<form id="searchForm"  action="${ctx}/cms/site/" method="post" class="layui-form layui-card-header layuiadmin-card-header-auto">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">名称：</label>
				<div class="layui-input-block">
					<input type="text" name="name" value="${site.name}" htmlEscape="false" maxlength="50" class="layui-input"/>
				</div>
			</div>

			<div class="layui-inline">
				<label class="layui-form-label">状态:</label>
				<div class="layui-input-block">
					<#radio  name="delFlag" items="${@DictUtils.getDictList('del_flag')}" value="${site.delFlag}" />
				</div>
			</div>
		
			<div class="layui-inline">
				<button class="layui-btn layuiadmin-btn-useradmin" lay-submit="" lay-filter="LAY-enrollList-search">
					<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
				</button>
			</div>
		</div>
	</form>
	<div class="layui-card-body">
		<#message content="${message!}"/>
		<%if(shiro.hasPermission("cms:site:edit")){%>
		<div>
			<button class="layui-btn layui-btn-normal LAY_ADD_site_btn"><i class="layui-icon layui-icon-add-1"></i>站点添加</button>
		</div>
		<%}%>
		<table id="contentTable" class="layui-table" >
			<thead>
				<tr>
					<th style="text-align:center">名称</th>
					<th style="text-align:center">标题</th>
					<th style="text-align:center">描述</th>
					<th style="text-align:center">关键字</th>
					<th style="text-align:center">主题</th>
					<%if(shiro.hasPermission("cms:site:edit")){%>
					<th style="text-align:center">操作</th>
					<%}%>
				</tr>
			</thead>
			<tbody>
				<%for(site in page.list){%>
				<tr>
					<td><a href="${ctx}/cms/site/form?id=${site.id}" title="${site.name}">${@StringUtils.abbr(site.name,40)}</a></td>
					<td>${@StringUtils.abbr(site.title,40)}</td>
					<td>${@StringUtils.abbr(site.description,40)}</td>
					<td>${@StringUtils.abbr(site.keywords,40)}</td>
					<td>${site.theme}</td>
					<%if(shiro.hasPermission("cms:site:edit")){%><td style="text-align:center">
						<a class="layui-btn layui-btn-xs" onclick="editSite('${site.id}')" href="javascript:void(0);">修改</a>
						<a class="layui-btn layui-btn-danger layui-btn-xs" href="${ctx}/cms/site/delete?id=${site.id}${site.delFlag != '0'?'&isRe=true':''}" onclick="return confirmx('确认要${site.delFlag != '0'?'恢复':''}删除该站点吗？', this.href)" >${site.delFlag != '0'?'恢复':''}删除</a>
					</td>
					<%}%>
				</tr>
				<%}%>
			</tbody>
		</table>
		<div class="pagination">${page}</div>
	</div>
	</div>
</div>
<script>
    layui.use(['form','layer'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery;
        //添加
        $(".LAY_ADD_site_btn").click(function(){
            var index = layui.layer.open({
                title : "添加站点",
                type : 2,
                content : "${ctx}/cms/site/form",
                maxmin: true,
                area: ['100%', '100%'],
                btn: ['确定', '取消'],
                yes: function(index, layero){
                    var submit = layero.find('iframe').contents().find('#siteForm');
                    submit.trigger('click');
                    layer.close(index);
                },
                end:function(){
                    location.reload();
                }
            })
        })
    })
    var editSite = function(id){
        var index = layui.layer.open({
            title : "修改站点",
            type : 2,
            content : "${ctx}/cms/site/form?id="+id,
            maxmin: true,
            area: ['100%', '100%'],
            btn: ['确定', '取消'],
            yes: function(index, layero){
                var submit = layero.find('iframe').contents().find('#siteForm');
                submit.trigger('click');
                layer.close(index);
            },
            end:function(){
                location.reload();
            }
        })
    }
</script>
<%}%>